package main

import (
	"fmt"
)

func main() {
	var mm []int = []int{1, 2, 3, 4, 5, 6}
	printSlice(mm)
	mm = append(mm, 1, 2)
	printSlice(mm)

	var numbers = make([]int, 3, 5)
	printSlice(numbers)
	numbers = append(numbers, 5, 6, 7)
	printSlice(numbers)

	var numbers2 []int
	if numbers2 == nil {
		fmt.Println("这是一个空指针")
	}

	printSlice(numbers2)
	copy(numbers2, numbers)
	printSlice(numbers2)
	printSlice(numbers)

	numbers3 := make([]int, 6, 10)
	if numbers3 == nil {
		fmt.Println("这是一个空指针")
	}
	printSlice(numbers3)
	copy(numbers3, numbers)
	printSlice(numbers3)
}

func printSlice(x []int) {
	fmt.Printf("len: %d  cap: %d  slice: %v\n", len(x), cap(x), x)
}
